//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for ElasticLoadBalancing
public struct ElasticLoadBalancingErrorType: AWSErrorType {
    enum Code: String {
        case accessPointNotFoundException = "LoadBalancerNotFound"
        case certificateNotFoundException = "CertificateNotFound"
        case dependencyThrottleException = "DependencyThrottle"
        case duplicateAccessPointNameException = "DuplicateLoadBalancerName"
        case duplicateListenerException = "DuplicateListener"
        case duplicatePolicyNameException = "DuplicatePolicyName"
        case duplicateTagKeysException = "DuplicateTagKeys"
        case invalidConfigurationRequestException = "InvalidConfigurationRequest"
        case invalidEndPointException = "InvalidInstance"
        case invalidSchemeException = "InvalidScheme"
        case invalidSecurityGroupException = "InvalidSecurityGroup"
        case invalidSubnetException = "InvalidSubnet"
        case listenerNotFoundException = "ListenerNotFound"
        case loadBalancerAttributeNotFoundException = "LoadBalancerAttributeNotFound"
        case operationNotPermittedException = "OperationNotPermitted"
        case policyNotFoundException = "PolicyNotFound"
        case policyTypeNotFoundException = "PolicyTypeNotFound"
        case subnetNotFoundException = "SubnetNotFound"
        case tooManyAccessPointsException = "TooManyLoadBalancers"
        case tooManyPoliciesException = "TooManyPolicies"
        case tooManyTagsException = "TooManyTags"
        case unsupportedProtocolException = "UnsupportedProtocol"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize ElasticLoadBalancing
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// The specified load balancer does not exist.
    public static var accessPointNotFoundException: Self { .init(.accessPointNotFoundException) }
    /// The specified ARN does not refer to a valid SSL certificate in AWS Identity and Access Management (IAM) or AWS Certificate Manager (ACM). Note that if you recently uploaded the certificate to IAM, this error might indicate that the certificate is not fully available yet.
    public static var certificateNotFoundException: Self { .init(.certificateNotFoundException) }
    /// A request made by Elastic Load Balancing to another service exceeds the maximum request rate permitted for your account.
    public static var dependencyThrottleException: Self { .init(.dependencyThrottleException) }
    /// The specified load balancer name already exists for this account.
    public static var duplicateAccessPointNameException: Self { .init(.duplicateAccessPointNameException) }
    /// A listener already exists for the specified load balancer name and port, but with a different instance port, protocol, or SSL certificate.
    public static var duplicateListenerException: Self { .init(.duplicateListenerException) }
    /// A policy with the specified name already exists for this load balancer.
    public static var duplicatePolicyNameException: Self { .init(.duplicatePolicyNameException) }
    /// A tag key was specified more than once.
    public static var duplicateTagKeysException: Self { .init(.duplicateTagKeysException) }
    /// The requested configuration change is not valid.
    public static var invalidConfigurationRequestException: Self { .init(.invalidConfigurationRequestException) }
    /// The specified endpoint is not valid.
    public static var invalidEndPointException: Self { .init(.invalidEndPointException) }
    /// The specified value for the schema is not valid. You can only specify a scheme for load balancers in a VPC.
    public static var invalidSchemeException: Self { .init(.invalidSchemeException) }
    /// One or more of the specified security groups do not exist.
    public static var invalidSecurityGroupException: Self { .init(.invalidSecurityGroupException) }
    /// The specified VPC has no associated Internet gateway.
    public static var invalidSubnetException: Self { .init(.invalidSubnetException) }
    /// The load balancer does not have a listener configured at the specified port.
    public static var listenerNotFoundException: Self { .init(.listenerNotFoundException) }
    /// The specified load balancer attribute does not exist.
    public static var loadBalancerAttributeNotFoundException: Self { .init(.loadBalancerAttributeNotFoundException) }
    /// This operation is not allowed.
    public static var operationNotPermittedException: Self { .init(.operationNotPermittedException) }
    /// One or more of the specified policies do not exist.
    public static var policyNotFoundException: Self { .init(.policyNotFoundException) }
    /// One or more of the specified policy types do not exist.
    public static var policyTypeNotFoundException: Self { .init(.policyTypeNotFoundException) }
    /// One or more of the specified subnets do not exist.
    public static var subnetNotFoundException: Self { .init(.subnetNotFoundException) }
    /// The quota for the number of load balancers has been reached.
    public static var tooManyAccessPointsException: Self { .init(.tooManyAccessPointsException) }
    /// The quota for the number of policies for this load balancer has been reached.
    public static var tooManyPoliciesException: Self { .init(.tooManyPoliciesException) }
    /// The quota for the number of tags that can be assigned to a load balancer has been reached.
    public static var tooManyTagsException: Self { .init(.tooManyTagsException) }
    /// The specified protocol or signature version is not supported.
    public static var unsupportedProtocolException: Self { .init(.unsupportedProtocolException) }
}

extension ElasticLoadBalancingErrorType: Equatable {
    public static func == (lhs: ElasticLoadBalancingErrorType, rhs: ElasticLoadBalancingErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension ElasticLoadBalancingErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
